home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.3 / GetCursor.3 < prev    next >
Text File  |  1995-07-25  |  16KB  |  265 lines

  1.  
  2.  
  3.  
  4.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           Tk_GetCursor,     Tk_GetCursorFromData,     Tk_NameOfCursor,
  12.           Tk_FreeCursor - maintain database of cursors
  13.  
  14.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  15.           ####iiiinnnncccclllluuuuddddeeee <<<<ttttkkkk....hhhh>>>>
  16.  
  17.           Cursor
  18.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((_i_n_t_e_r_p, _t_k_w_i_n, _n_a_m_e_I_d))))
  19.  
  20.           Cursor
  21.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa((((_i_n_t_e_r_p, _t_k_w_i_n, _s_o_u_r_c_e, _m_a_s_k, _w_i_d_t_h, _h_e_i_g_h_t, _x_H_o_t, _y_H_o_t, _f_g, _b_g))))
  22.  
  23.           char *
  24.           TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr((((_d_i_s_p_l_a_y, _c_u_r_s_o_r))))                              |
  25.  
  26.           TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr((((_d_i_s_p_l_a_y, _c_u_r_s_o_r))))                                |
  27.  
  28.      AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  29.           Tcl_Interp      *_i_n_t_e_r_p     (in)      Interpreter to use for
  30.                                                 error reporting.
  31.  
  32.           Tk_Window       _t_k_w_i_n       (in)      Token  for  window  in
  33.                                                 which  the cursor will
  34.                                                 be used.
  35.  
  36.           Tk_Uid          _n_a_m_e_I_d      (in)      Description of cursor;
  37.                                                 see below for possible
  38.                                                 values.
  39.  
  40.           char            *_s_o_u_r_c_e     (in)      Data    for     cursor
  41.                                                 bitmap,   in  standard
  42.                                                 bitmap format.
  43.  
  44.           char            *_m_a_s_k       (in)      Data for mask  bitmap,
  45.                                                 in   standard   bitmap
  46.                                                 format.
  47.  
  48.           unsigned int    _w_i_d_t_h       (in)      Width  of  _s_o_u_r_c_e  and
  49.                                                 _m_a_s_k.
  50.  
  51.           unsigned int    _h_e_i_g_h_t      (in)      Height of  _s_o_u_r_c_e  and
  52.                                                 _m_a_s_k.
  53.  
  54.           unsigned int    _x_H_o_t        (in)      X-location  of  cursor
  55.                                                 hot-spot.
  56.  
  57.           unsigned int    _y_H_o_t        (in)      Y-location  of  cursor
  58.                                                 hot-spot.
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/23/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))
  71.  
  72.  
  73.  
  74.           Tk_Uid          _f_g          (in)      Textual description of
  75.                                                 foreground  color  for
  76.                                                 cursor.
  77.  
  78.           Tk_Uid          _b_g          (in)      Textual description of
  79.                                                 background  color  for
  80.                                                 cursor.
  81.  
  82.           Display         *_d_i_s_p_l_a_y    (in)      Display   for    which
  83.                                                 _c_u_r_s_o_r was allocated.   |
  84.  
  85.           Cursor          _c_u_r_s_o_r      (in)      X    identifier    for
  86.                                                 cursor.    If   passed
  87.                                                 toTTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr,  must
  88.                                                 have  been returned by
  89.                                                 some previous call  to
  90.                                                 TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr        or
  91.                                                 TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa.
  92.      _________________________________________________________________
  93.  
  94.  
  95.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  96.           These procedures manage a collection of cursors  being  used
  97.           by  an  application.  The procedures allow cursors to be re-
  98.           used efficiently, thereby avoiding server overhead, and also
  99.           allow  cursors  to be named with character strings (actually
  100.           Tk_Uids).
  101.  
  102.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr takes as argument a Tk_Uid describing a cursor,
  103.           and  returns  the X identifier for a cursor corresponding to
  104.           the description.  It re-uses an existing cursor if  possible
  105.           and  creates a new one otherwise.  _N_a_m_e_I_d must be a standard
  106.           Tcl list with one of the following forms:
  107.  
  108.           _n_a_m_e  [_f_g_C_o_l_o_r  [_b_g_C_o_l_o_r]]
  109.                _N_a_m_e is the name of a cursor in the standard  X  cursor
  110.                font,  i.e.,  any of the names defined in ccccuuuurrrrssssoooorrrrffffoooonnnntttt....hhhh,
  111.                without the XXXXCCCC____.  Some  example  values  are  XXXX____ccccuuuurrrrssssoooorrrr,
  112.                hhhhaaaannnndddd2222,  or  lllleeeefffftttt____ppppttttrrrr.   Appendix  B  of  ``The X Window
  113.                System''  by  Scheifler  &  Gettys  has   illustrations
  114.                showing  what  each  of  these  cursors looks like.  If
  115.                _f_g_C_o_l_o_r and _b_g_C_o_l_o_r are both specified, they  give  the
  116.                foreground  and background colors to use for the cursor
  117.                (any of the forms  acceptable  to  TTTTkkkk____GGGGeeeettttCCCCoooolllloooorrrr  may  be
  118.                used).   If  only _f_g_C_o_l_o_r is specified, then there will
  119.                be  no  background  color:   the  background  will   be
  120.                transparent.   If  no  colors  are  specified, then the
  121.                cursor will use black  for  its  foreground  color  and
  122.                white for its background color.
  123.  
  124.           @@@@_s_o_u_r_c_e_N_a_m_e  _m_a_s_k_N_a_m_e  _f_g_C_o_l_o_r  _b_g_C_o_l_o_r
  125.                In this form, _s_o_u_r_c_e_N_a_m_e and _m_a_s_k_N_a_m_e are the names  of
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/23/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))
  137.  
  138.  
  139.  
  140.                files  describing  bitmaps for the cursor's source bits
  141.                and mask.  Each file must be in  standard  X11  or  X10
  142.                bitmap format.  _F_g_C_o_l_o_r and _b_g_C_o_l_o_r indicate the colors
  143.                to use for the cursor, in any of the  forms  acceptable
  144.                to TTTTkkkk____GGGGeeeettttCCCCoooolllloooorrrr.
  145.  
  146.           @@@@_s_o_u_r_c_e_N_a_m_e  _f_g_C_o_l_o_r
  147.                This form is similar to the one above, except that  the
  148.                source  is  used  as  mask  also.   This means that the
  149.                cursor's background is transparent.
  150.  
  151.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa allows cursors to be created  from  in-
  152.           memory  descriptions  of  their  source  and  mask  bitmaps.
  153.           _S_o_u_r_c_e points to  standard  bitmap  data  for  the  cursor's
  154.           source  bits,  and  _m_a_s_k  points  to  standard  bitmap  data
  155.           describing which pixels of _s_o_u_r_c_e are to be drawn and  which
  156.           are to be considered transparent.  _W_i_d_t_h and _h_e_i_g_h_t give the
  157.           dimensions  of  the  cursor,  _x_H_o_t  and  _y_H_o_t  indicate  the
  158.           location  of  the  cursor's  hot-spot  (the  point  that  is
  159.           reported when an event occurs), and _f_g and _b_g  describe  the
  160.           cursor's  foreground and background colors textually (any of
  161.           the forms suitable for TTTTkkkk____GGGGeeeettttCCCCoooolllloooorrrr may be used).  Typically,
  162.           the   arguments   to  TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa  are  created  by
  163.           including a cursor file directly into the source code for  a
  164.           program, as in the following example:
  165.                Cursor cursor;
  166.                #include "source.cursor"
  167.                #include "mask.cursor"
  168.                cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
  169.                                mask_bits, source_width, source_height, source_x_hot,
  170.                                source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));
  171.  
  172.           Under     normal      conditions,      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr      and
  173.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa  will  return  an  identifier  for  the
  174.           requested cursor.   If  an  error  occurs  in  creating  the
  175.           cursor,  such  as when _n_a_m_e_I_d refers to a non-existent file,
  176.           then NNNNoooonnnneeee is returned and an error message will be stored in
  177.           _i_n_t_e_r_p->_r_e_s_u_l_t.
  178.  
  179.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr and TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa maintain a database of
  180.           all  the  cursors  they  have created.  Whenever possible, a
  181.           call to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr or TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa will return  an
  182.           existing  cursor  rather  than  creating  a  new  one.  This
  183.           approach can substantially reduce server overhead, so the Tk
  184.           procedures  should  generally  be used in preference to Xlib
  185.           procedures like  XXXXCCCCrrrreeeeaaaatttteeeeFFFFoooonnnnttttCCCCuuuurrrrssssoooorrrr  or  XXXXCCCCrrrreeeeaaaatttteeeePPPPiiiixxxxmmmmaaaappppCCCCuuuurrrrssssoooorrrr,
  186.           which create a new cursor on each call.
  187.  
  188.           The procedure TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr  is  roughly  the  inverse  of
  189.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr.    If  its  _c_u_r_s_o_r  argument  was  created  by
  190.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr, then the return value is the  _n_a_m_e_I_d  argument
  191.           that  was  passed  to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr to create the cursor.  If
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 7/23/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333))))
  203.  
  204.  
  205.  
  206.           _c_u_r_s_o_r was created by a call to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa, or  by
  207.           any  other mechanism, then the return value is a hexadecimal
  208.           string giving the X identifier for the cursor.   Note:   the
  209.           string  returned  by  TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr  is only guaranteed to
  210.           persist until the next call to TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr.
  211.  
  212.           When    a    cursor    returned    by    TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr     or
  213.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa  is  no  longer  needed,  TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr
  214.           should be called to release it.  There should be exactly one
  215.           call  to  TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr  for  each  call  to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr or
  216.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa.  When a cursor is  no  longer  in  use
  217.           anywhere  (i.e.  it  has  been freed as many times as it has
  218.           been gotten) TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr will release it to the  X  server
  219.           and remove it from the database.
  220.  
  221.  
  222.      BBBBUUUUGGGGSSSS
  223.           In determining whether an existing cursor  can  be  used  to
  224.           satisfy a new request, TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr and TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa
  225.           consider only the immediate values of their arguments.   For
  226.           example,  when  a  file  name  is  passed  to  TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr,
  227.           TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr will assume it is safe to  re-use  an  existing
  228.           cursor  created  from the same file name:  it will not check
  229.           to see whether the file itself has changed, or  whether  the
  230.           current  directory  has changed, thereby causing the name to
  231.           refer to a different file.  Similarly,  TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa
  232.           assumes  that  if  the  same  _s_o_u_r_c_e  pointer is used in two
  233.           different calls, then the pointers refer to the  same  data;
  234.           it  does  not  check  to  see if the actual data values have
  235.           changed.
  236.  
  237.  
  238.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  239.           cursor
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 7/23/95)
  262.  
  263.  
  264.  
  265.